/**
 * @author zhoushengtao
 * @since 2012-8-27 下午9:00:32
 */

package com.stchou.superbrowser.activity;

import com.stchou.superbrowser.ui.adapter.NavgationAdapter;
import com.stchou.superbrowser.ui.widget.SuperImageButton;
import com.stchou.superbrowser.utils.ResManager;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.webkit.WebView;
import android.widget.EditText;
import android.widget.GridView;

public class IndexActivity extends Activity implements OnClickListener, OnTouchListener
{
    public static final String BAIDU_GATE = "http://gate.baidu.com/tc?from=opentc&src=";
    private GridView m_gridView;
    private WebView m_superWebview;
    // nav bar
    private SuperImageButton m_menuButton;
    private SuperImageButton m_tabButton;
    private SuperImageButton m_homeButton;
    // title bar
    private EditText m_webSiteText;
    private EditText m_searchText;

    

    
    
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_index);
        initView();
    }

    /**
     * 初始化 views
     */
    private void initView()
    {

        m_gridView = (GridView)findViewById(R.id.gridView);
        m_gridView.setAdapter(new NavgationAdapter(this,ResManager.m_quckLinkImages, ResManager.m_quckLinkTexts));

        

        
        m_superWebview = (WebView)findViewById(R.id.weather_webview);
        m_superWebview.loadUrl("file:///android_asset/weather.html");
        
        m_menuButton = (SuperImageButton)findViewById(R.id.superImageButton3);
        m_menuButton.setOnClickListener(this);

        m_tabButton = (SuperImageButton)findViewById(R.id.superImageButton4);
        m_tabButton.setOnClickListener(this);

        m_homeButton = (SuperImageButton)findViewById(R.id.superImageButton5);
        m_homeButton.setOnClickListener(this);

        m_webSiteText = (EditText)findViewById(R.id.website_text);
        m_webSiteText.setOnTouchListener(this);

        m_searchText = (EditText)findViewById(R.id.search_text);
        m_searchText.setOnTouchListener(this);

 
    }

    @Override
    public void onClick(View v)
    {
     
    }

    @Override
    public boolean onTouch(View v, MotionEvent event)
    {
        Intent intent;
        if ((event.getAction() == MotionEvent.ACTION_DOWN))
            switch (v.getId())
            {
                case R.id.website_text:
                    intent = new Intent(IndexActivity.this, InputWebsiteActivity.class);
                    startActivity(intent);
                    break;
                case R.id.search_text:
                    intent = new Intent(IndexActivity.this, SearchActivity.class);
                    startActivity(intent);
                    break;
            }
        return false;
    }

}
